//
//  TSAutoFillViewController.m
//  MirkoLibTest
//
//  Created by Mirko on 2017/3/31.
//  Copyright © 2017年 Mirko. All rights reserved.
//

#import "TSAutoFillViewController.h"
#import "TSTableViewViewController.h"
#import "TSViewAutoFillViewController.h"
#import <objc/runtime.h>

static const NSString *kTestKey1 = @"test_key_1";
static const NSString *kTestKey2 = @"test_key_2";

@interface TSAutoFillViewController ()

@property (nonatomic, weak) BasicTestViewController *tableTs;
@property (nonatomic, weak) BasicTestViewController *viewTs;

@end

@implementation TSAutoFillViewController

-(void) viewDidLoad
{
    [super viewDidLoad];
    [self addRightBttonAction:nil];

}

-(void) handleRightBtnAction:(UIButton *)button
{
    TSTableViewViewController *vc = [TSTableViewViewController loadIBVCIdentifier:nil];
    [self.navigationController pushViewController:vc animated:YES];
}

-(void) handelAction:(UINavigationController *)navController
{
    [navController pushViewController:self animated:YES];
}
- (IBAction)btn1Action:(id)sender {
//    TSTableViewViewController *vc = [TSTableViewViewController loadIBVCIdentifier:nil];
//    NSString *sting = @"adsadf";
//    
//    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
//    
//    [self.view addSubview:view];
    
    if (!self.tableTs) {
        self.tableTs = [TSTableViewViewController loadIBVCIdentifier:nil];
    }
    [self.navigationController pushViewController:self.tableTs animated:YES];
    
//    objc_setAssociatedObject(self, &kTestKey1, vc, OBJC_ASSOCIATION_ASSIGN);
    
}
- (IBAction)btn2Action:(id)sender {
    self.viewTs = [TSViewAutoFillViewController loadIBVCIdentifier:nil];
    [self.navigationController pushViewController:self.viewTs animated:YES];
//    objc_setAssociatedObject(self, &kTestKey2, vc, OBJC_ASSOCIATION_ASSIGN);
}

//-(void) dealloc
//{
//    self.tableTs = nil;
//    self.tableTs = nil;
//    self.tableTs = nil;
//    self.viewTs = nil;
//    NSLog(@"%s", __PRETTY_FUNCTION__);
//}

//-(void) dealloc
//{
//    TSTableViewViewController *vc1 = objc_getAssociatedObject(self, &kTestKey1);
//    TSViewAutoFillViewController *vc2 = objc_getAssociatedObject(self, &kTestKey2);
//    
//    objc_setAssociatedObject(self, nil, vc1, OBJC_ASSOCIATION_ASSIGN);
//    NSLog(@"TSTableViewViewController :%@, TSViewAutoFillViewController :%@", vc1, vc2);
//}

@end
